/* 墨水屏设备外观 */
body {
    margin: 0;
    padding: 20px;
    background: #f0f2f5;
    font-family: 'Microsoft YaHei', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.device-frame {
    width: 800px;
    height: 600px;
    background: #1f1f1f;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    display: flex;
}

.screen-container {
    flex: 1;
    background: #fafafa;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    color: #333;
}

/* 状态栏 */
.status-bar {
    height: 30px;
    background: #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    font-size: 12px;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.settings-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #555;
    transition: transform 0.2s;
}

.settings-btn:hover {
    transform: rotate(30deg);
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* 题目区域 - 压缩空间 */
.question-area {
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.question-header h3 {
    margin: 0;
    color: #333;
    font-size: 14px;
}

.progress-indicator {
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
}

.question-content {
    font-size: 13px;
    line-height: 1.4;
    min-height: 40px;
    padding: 12px;
    background: #f8f8f8;
    border-radius: 6px;
    border-left: 3px solid #4CAF50;
    transition: all 0.3s ease;
}

/* 手写输入区域 */
.writing-area {
    flex: 1;
    min-height: 200px; /* 确保有最小书写高度 */
    padding: 15px;
    background: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
}

#writingCanvas {
    width: 100%;
    height: 100%;
    border: 1px dashed #ccc;
    cursor: crosshair;
    background: #fff;
    border-radius: 5px;
    flex: 1;
}

.canvas-tools {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.canvas-tools button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.canvas-tools button:hover {
    background: #e0e0e0;
}

/* 浮动的题目切换按钮 */
.floating-nav-buttons {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 20;
}

.floating-nav-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-nav-btn:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.1);
}

.floating-nav-btn:disabled {
    background: rgba(0, 0, 0, 0.2);
    cursor: not-allowed;
    opacity: 0.5;
}

/* AI助手区域 - 固定在右下角 */
.ai-assistant {
    position: fixed;
    bottom: 85px;
    right: 20px;
    width: 360px;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f2ff 100%);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: all 0.3s ease;
    max-height: 280px;
    overflow: visible; /* 改为visible以容纳按钮 */
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
    z-index: 1000;
    border: 2px solid #e3f2fd;
    padding: 18px;
    padding-top: 28px; /* 增加顶部内边距为按钮留出空间 */
}

.ai-assistant.collapsed {
    width: 60px;
    height: 60px;
    padding: 8px;
    border-radius: 50%;
    gap: 0;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ai-assistant.collapsed .assistant-content {
    display: none;
}

.ai-assistant.collapsed .assistant-avatar {
    margin: 0;
    width: 40px;
    height: 40px;
    font-size: 24px;
}

.assistant-avatar {
    font-size: 28px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(79, 195, 247, 0.3);
}

.assistant-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative; /* 为按钮定位提供参考 */
}

.assistant-message {
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a1a;
    background: rgba(255, 255, 255, 0.8);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    border-left: 3px solid #4fc3f7;
}

/* 帮助级别指示器 */
.help-level-indicator {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.help-level-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e0e0e0;
    transition: all 0.3s ease;
}

.help-level-dot.active {
    background: #4fc3f7;
    box-shadow: 0 2px 8px rgba(79, 195, 247, 0.4);
}

/* 继续引导按钮 - 仅图标 */
.continue-guide-btn {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
    transition: all 0.3s ease;
    display: none; /* 默认隐藏，由JS控制显示 */
    align-items: center;
    justify-content: center;
    position: fixed; /* 改为固定定位，相对于视口 */
    bottom: 87px; /* 与ai-assistant容器底部对齐 */
    right: 75px; /* 距离右边75px，在聊天按钮左侧 */
    z-index: 1001; /* 确保在ai-assistant之上 */
}

.continue-guide-btn:hover {
    background: linear-gradient(135deg, #f57c00, #ef6c00);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 152, 0, 0.4);
}

.continue-guide-btn:disabled {
    background: #bdbdbd;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 6px rgba(189, 189, 189, 0.3);
}

/* 聊天功能样式 */
.chat-input-area {
    margin-top: 10px;
    padding: 12px;
    background: rgba(255,255,255,0.9);
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input-area input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.chat-input-area input:focus {
    border-color: #4fc3f7;
    box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
}

.chat-input-area button {
    padding: 8px 12px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

#sendChatBtn {
    background: #4fc3f7;
    color: white;
}

#sendChatBtn:hover {
    background: #29b6f6;
}

#closeChatBtn {
    background: #f44336;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#closeChatBtn:hover {
    background: #d32f2f;
}

.chat-toggle-btn {
    position: fixed; /* 改为固定定位，与继续引导按钮一致 */
    bottom: 87px; /* 与ai-assistant容器底部对齐 */
    right: 35px; /* 距离右边35px */
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    width: 36px; /* 与继续引导按钮尺寸一致 */
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
    z-index: 1001; /* 确保在ai-assistant之上 */
}

.ai-assistant.collapsed .chat-toggle-btn,
.ai-assistant.collapsed .continue-guide-btn {
    display: none;
}

.chat-toggle-btn:hover {
    background: linear-gradient(135deg, #45a049, #388e3c);
    transform: scale(1.1);
}

/* 答题正确状态 */
.question-content.correct {
    background: linear-gradient(135deg, #e8f5e8 0%, #f1f8e9 100%);
    border-left: 4px solid #4CAF50;
    box-shadow: 0 2px 12px rgba(76, 175, 80, 0.2);
    position: relative;
}

.question-content.correct::after {
    content: "✅ 答题正确！";
    position: absolute;
    top: -10px;
    right: 15px;
    background: #4CAF50;
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    animation: success-bounce 0.6s ease-out;
}

@keyframes success-bounce {
    0% { transform: scale(0) translateY(10px); opacity: 0; }
    50% { transform: scale(1.2) translateY(-5px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* 助手状态样式 */
.ai-assistant.urgent {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-color: #ff9800;
    animation: gentle-pulse 2s infinite;
}

.ai-assistant.success {
    background: linear-gradient(135deg, #e8f5e8 0%, #f1f8e9 100%);
    border-color: #4CAF50;
    animation: success-glow 2s ease-in-out;
}

.ai-assistant.monitoring-active {
    border-color: #4CAF50;
    box-shadow: 0 12px 32px rgba(76, 175, 80, 0.2);
}

.ai-assistant.monitoring-active .assistant-avatar {
    animation: monitoring-pulse 2s infinite;
}

@keyframes gentle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

@keyframes success-glow {
    0%, 100% { box-shadow: 0 12px 32px rgba(76, 175, 80, 0.2); }
    50% { box-shadow: 0 12px 32px rgba(76, 175, 80, 0.4); }
}

@keyframes monitoring-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 智能监控中心 - 悬浮在右侧 */
.debug-panel {
    position: fixed;
    top: 50px;
    right: 50px;
    width: 280px;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 15px;
    border-radius: 12px;
    font-size: 11px;
    z-index: 1600;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    border: 2px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.debug-panel.collapsed {
    width: 50px;
    height: 50px;
    padding: 8px;
    overflow: hidden;
}

.debug-panel.collapsed .monitoring-content,
.debug-panel.collapsed .monitoring-controls,
.debug-panel.collapsed .monitoring-status {
    display: none;
}

.debug-panel h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #4CAF50;
    text-align: center;
    cursor: pointer;
    position: relative;
}

.debug-panel.collapsed h4 {
    margin: 0;
    font-size: 20px;
    line-height: 1;
}

.debug-panel h4::after {
    content: '📊';
    position: absolute;
    right: 0;
    top: 0;
    cursor: pointer;
    font-size: 16px;
}

.debug-panel.collapsed h4::after {
    content: '📊';
    position: static;
    font-size: 24px;
}

.monitoring-content {
    font-size: 11px;
    line-height: 1.4;
    color: white;
    margin-bottom: 15px;
    background: rgba(255,255,255,0.1);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
}

.monitoring-controls {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.monitor-btn {
    flex: 1;
    padding: 6px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s;
    color: white;
    font-weight: bold;
}

.start-btn {
    background: #4CAF50;
}

.start-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.stop-btn {
    background: #f44336;
}

.stop-btn:hover {
    background: #da190b;
    transform: translateY(-1px);
}

.restart-btn {
    background: #ff9800;
}

.restart-btn:hover {
    background: #f57c00;
    transform: translateY(-1px);
}

.monitoring-status {
    text-align: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 10px;
    color: white;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: #4CAF50;
    box-shadow: 0 0 6px #4CAF50;
}

.status-dot.offline {
    background: #f44336;
    box-shadow: 0 0 6px #f44336;
}

.status-dot.analyzing {
    background: #ff9800;
    box-shadow: 0 0 6px #ff9800;
    animation: pulse 0.5s infinite;
}

.status-dot.correct {
    background: #4CAF50;
    animation: success-pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes success-pulse {
    0%, 100% { 
        background: #4CAF50;
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    50% { 
        background: #66BB6A;
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
}

/* 功能演示面板 - 添加滚动支持 */
.demo-panel {
    position: fixed;
    top: 100px;
    left: 20px;
    width: 240px;
    max-height: 70vh; /* 限制最大高度 */
    background: #fff;
    color: #333;
    padding: 0;
    border-radius: 12px;
    font-size: 12px;
    z-index: 1500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
    overflow: hidden; /* 隐藏溢出内容 */
}

.demo-panel.hidden {
    transform: translateX(-120%);
    opacity: 0;
    pointer-events: none;
}

.demo-panel h4 {
    margin: 0;
    padding: 15px 15px 10px 15px;
    font-size: 14px;
    color: #333;
    text-align: center;
    position: sticky;
    top: 0;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 10;
}

.demo-panel-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f0f0f0;
    color: #888;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.demo-panel-close:hover {
    background: #e0e0e0;
    color: #333;
}

.demo-panel-content {
    padding: 10px 15px 15px 15px;
    max-height: calc(70vh - 60px); /* 减去头部高度 */
    overflow-y: auto; /* 垂直滚动 */
    scrollbar-width: thin;
    scrollbar-color: #ccc #f0f0f0;
}

/* 美化滚动条 */
.demo-panel-content::-webkit-scrollbar {
    width: 6px;
}

.demo-panel-content::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.demo-panel-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.demo-panel-content::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.demo-item {
    margin-bottom: 8px;
}

.demo-item button {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
    color: #333;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    text-align: left;
}

.demo-item button:hover {
    background: #e9ecef;
    border-color: #28a745;
    transform: translateY(-1px);
}

.demo-instructions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.demo-instructions p {
    margin: 8px 0;
    line-height: 1.5;
    font-size: 11px;
}

.demo-instructions strong {
    color: #28a745;
}

/* 响应式设计 */
@media (max-width: 900px) {
    body {
        padding: 10px;
    }
    
    .device-frame {
        width: 100%;
        height: 80vh;
    }
}

/* 特殊状态样式 */
.thinking {
    opacity: 0.7;
}

.stuck {
    border-left-color: #ff9800 !important;
    background: #fff8e1 !important;
}

.helped {
    border-left-color: #4CAF50 !important;
    background: #f1f8e9 !important;
}

/* API配置对话框样式 */
.api-config-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

.api-config-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 2px solid #e3f2fd;
}

.api-config-content h3 {
    margin: 0 0 25px 0;
    text-align: center;
    color: #333;
    font-size: 20px;
    font-weight: bold;
}

.config-section {
    margin-bottom: 20px;
}

.config-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
    font-size: 14px;
}

.config-section input,
.config-section select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

.config-section input:focus,
.config-section select:focus {
    border-color: #4fc3f7;
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.1);
}

.config-section small {
    display: block;
    margin-top: 6px;
    color: #666;
    font-size: 12px;
    line-height: 1.4;
}

.config-buttons {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.config-buttons button {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.test-btn {
    background: linear-gradient(135deg, #9C27B0, #7B1FA2);
    color: white;
}

.test-btn:hover {
    background: linear-gradient(135deg, #7B1FA2, #6A1B9A);
    transform: translateY(-2px);
}

.save-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.save-btn:hover {
    background: linear-gradient(135deg, #45a049, #388e3c);
    transform: translateY(-2px);
}

.cancel-btn {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
}

.cancel-btn:hover {
    background: linear-gradient(135deg, #d32f2f, #c62828);
    transform: translateY(-2px);
}

.connection-status {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    background: #f5f5f5;
    min-height: 20px;
    font-size: 13px;
    border-left: 4px solid #e0e0e0;
}

/* 工具栏按钮美化 */
.toolbar {
    height: 70px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    gap: 20px;
}

.toolbar-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.toolbar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.toolbar-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.config-btn {
    background: linear-gradient(135deg, #2196f3, #1976d2);
    color: white;
}

.config-btn:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
}

.submit-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.submit-btn:hover {
    background: linear-gradient(135deg, #45a049, #388e3c);
}

.submit-btn:disabled {
    background: linear-gradient(135deg, #bdbdbd, #9e9e9e);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.btn-icon {
    font-size: 16px;
}

.btn-text {
    font-size: 14px;
}

/* 演示按钮美化 */
.demo-toggle-btn {
    position: fixed;
    top: 50px;
    left: 20px;
    background: linear-gradient(135deg, #28a745, #218838);
    color: white;
    border: none;
    padding: 12px 18px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    z-index: 1400;
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.3);
    transition: all 0.3s ease;
}

.demo-toggle-btn:hover {
    background: linear-gradient(135deg, #218838, #1e7e34);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.4);
} 